﻿@{
    ViewBag.Title = "容器采购入库登记";
    Layout = "~/Views/Shared/_ManufactureList.cshtml";
}
<link href="~/Content/css/container_purchaseInstockEditAdd.css" rel="stylesheet" />


<script type="text/javascript">
    $(function () {
        Index.init();
    });

    var Index = {
        rowData: null,
        FDocuNO: $.request("FDocuNO"),
        FHappenComNO: $.request("FHappenComNO"),
        FDescription_DOC: $.request("FDescription_DOC"),
        FCurDate: $.request("FCurDate"),
        FCredence: $.request("FCredence"),
        isFormal: 1 == $.request("isFormal"),
        init: function () {
            with (Index) {
                initControl();

                loadDataList();
            }
        },
        initControl: function () {
            $("#FDocuNO").val(Index.FDocuNO);

            $("#FHappenComNO").prop("disabled", Index.isFormal);

            $("#FDescription_DOC").prop("disabled", Index.isFormal);

            $("#FCurDate").prop("disabled", Index.isFormal);

            $("#FCredence").prop("disabled", Index.isFormal);

            $("#FDescription_DOC").val(Index.FDescription_DOC);

            $("#FCurDate").val(Index.FCurDate);

            $("#FCredence").val(Index.FCredence);

            $.renderMy97Datepicker();
            //绑定容器编码列表
            $("#FContainerNO").bindSelect({
                url: "/WareHouse/Container/GetContainerNOList",
                id: "FContainerNO",
                text: "FContainerNOName"
            });
            //绑定来料单位
            $("#FHappenComNO").bindSelect({
                url: "/WareHouse/Container/GetSupplierJson",
                id: "UnitNO",
                text: "UnitNOShortName"
            });
            $("#FHappenComNO").val(Index.FHappenComNO);
            //绑定仓库编号列表
            $("#FStoreNO").bindSelect({
                url: "/WareHouse/Container/GetFStoreNOList",
                id: "FStoreNO",
                text: "FStoreNOName"
            });
            //绑定发生方式列表
            $("#FDocuTypeNo").bindSelect({
                url: "/WareHouse/Container/GetDocuType?FTypeNO=RG",
                id: "FTypeNO",
                text: "FTypeNOName"
            });
            //批次查询 btn_search1
            $("#btn_search1").on("click", function () {
                var $gridList1 = $("#gridList1");

                var conn1 = $.buildPostParam("FContainerNO", "1");

                $gridList1.jqGrid('setGridParam', {
                    postData: conn1,
                }).trigger('reloadGrid');
            });

            $("#FContainerNO").on("change", function () {
                var jsonData = JSON.parse($(this).find("option:selected").attr("obj"));

                var cols = "FContainerName,FStoreNO,FContainerTypeNO,FContainerTypeNOName".split(",");

                cols.forEach(function (item) {
                    $("#{0}".format(item)).val(jsonData[item]);
                });

                $("#FStoreNO").trigger("change");

                $('select').bindSelect();
            });

            $("#FStoreNO").on("change", function () {
                $("#FStoreSetNO").empty().bindSelect({
                    url: "/WareHouse/Container/GetFStoreSetNO?FStoreNO={0}".format($(this).val()),
                    id: "FStoreSetNO",
                    text: "FStoreSetNO"
                });
            });

            $('select').bindSelect();
        },
        loadDataList: function () {
            var conn1 = $.buildPostParam("FContainerNO", "1");

            var $gridList1 = $("#gridList1");

            $gridList1.dataGridForJson({
                url: "/WareHouse/Container/GetPurchaseInstockAdds",
                height: $(window).height() - 330,
                postData: conn1,
                colModel: [
                { label: '容器编号', name: 'FContainerNO', width: 120, align: 'left', sortable: false },
                { label: '容器名称', name: 'FContainerName', width: 160, align: 'left', sortable: false },
                { label: '单价(元)', name: 'FPrice', width: 80, align: 'right', sortable: false },
                { label: '仓库编号', name: 'FStoreNO', width: 120, align: 'left', sortable: false },
                { label: '仓库名称', name: 'FStoreName', width: 160, align: 'left', sortable: false },
                { label: '定置编号', name: 'FStoreSetNO', width: 120, align: 'left', sortable: false },
                 { label: '容器分类编号', name: 'FContainerTypeNO', width: 120, align: 'left', sortable: false, hidden: true },
                 { label: '容器分类编号名称', name: 'FContainerTypeNOName', width: 120, align: 'left', sortable: false, hidden: true },
                { label: '容器分类名称', name: 'FContainerTypeName', width: 160, align: 'left', sortable: false },
                { label: '', name: '', width: 170, align: 'left', sortable: false }
                ],
                pager: "#gridPager1",
                sortname: ' UseUnit, FContainerNO',
                sortorder: "",
                viewrecords: true,
                rownumWidth: 50,
                onSelectRow: function (rowId) {
                    var cols = "FContainerNO,FContainerName,FStoreNO,FStoreSetNO,FContainerTypeNO,FContainerTypeNOName".split(",");
                    
                    rowData = $gridList1.jqGrid('getRowData', rowId);

                    cols.forEach(function (item) {
                        $("#{0}".format(item)).val(rowData[item]);
                    });

                    $("#FStoreNO").trigger("change");

                    $('select').bindSelect();
                },
                loadComplete: function (data) {
                    Index.dataList = data;
                }
            });

            $gridList1.jqGrid('setFrozenColumns');

            $gridList1.jqGrid('setLabel', 0, '序号', 'rowNumberHeaderStyle');
        }
    };
</script>

<div class="layout" id="layout">
    <ul class="form_list">
        <li class="form_item form_item_3">
            <label>
                来料单位
            </label>
            <div class="input_c">
                <select id="FHappenComNO" name="" class="form-control">
                    <option value="">==请选择==</option>
                </select>
            </div>
            <div class="form_item_after">*</div>
        </li>
        <li class="form_item form_item_3">
            <label>摘要说明</label>
            <div class="input_c">
                <input id="FDescription_DOC" name="" placeholder="" type="text" class="form-control required" />
            </div>
            <div class="form_item_after">*</div>
        </li>
        <li class="form_item form_item_3">
            <label>单据编号</label>
            <div class="input_c">
                <input id="FDocuNO" name="" placeholder="" type="text" class="form-control required" readonly="readonly" />
            </div>
            <div class="form_item_after">*</div>
        </li>
        <li class="form_item form_item_3">
            <label>
                发生方式	
            </label>
            <div class="input_c">
                <select id="FDocuTypeNo" name="" class="form-control">
                </select>
            </div>
            <div class="form_item_after">*</div>
        </li>
        <li class="form_item form_item_3">
            <label>单据日期</label>
            <div class="input_c input_c_normal">
                <input id="FCurDate" name="" placeholder="" type="text" class="form-control required" my97date="yyyy-MM-dd" />
            </div>
            <div class="form_item_after">*</div>
        </li>
        <li class="form_item form_item_3">
            <label>凭证编号</label>
            <div class="input_c">
                <input id="FCredence" name="" placeholder="" type="text" class="form-control required" />
            </div>
            <div class="form_item_after">*</div>
        </li>

        <li class="form_item form_item_2">
            <label>
                容器编号
            </label>
            <div class="input_c input_c_2">
                <select id="FContainerNO" name="" class="form-control">
                    <option value="">==请选择==</option>
                </select>
            </div>
            <div class="form_item_after">*</div>
        </li>
        <li class="form_item form_item_2">
            <label>容器名称</label>
            <div class="input_c input_c_2">
                <input id="FContainerName" name="" placeholder="" type="text" class="form-control required" />
            </div>
            <div class="form_item_after">*</div>
        </li>
        <li class="form_item form_item_2">
            <label>仓库编号</label>
            <div class="input_c input_c_2">
                <select id="FStoreNO" name="" class="form-control">
                </select>
            </div>
            <div class="form_item_after">*</div>
        </li>
        <li class="form_item form_item_2">
            <label>定置编号</label>
            <div class="input_c input_c_1">
                <select id="FStoreSetNO" name="" class="form-control">
                </select>
            </div>
            <div class="form_item_after">*</div>
        </li>
        <li class="form_item form_item_2">
            <label>开票数量</label>
            <div class="input_c input_c_1 input_c_r">
                <input id="FQuantity_KP" name="" placeholder="" type="text" class="form-control required" />
            </div>
            <div class="form_item_aftern">件</div>
        </li>
        <li class="form_item form_item_2">
            <label>开票单价</label>
            <div class="input_c input_c_1 input_c_r">
                <input id="FPrice" name="" placeholder="" type="text" class="form-control required" />
            </div>
            <div class="form_item_aftern">元</div>
        </li>
        <li class="form_item form_item_2">
            <label>容器分类名称</label>
            <div class="input_c input_c_3">
                <input id="FContainerTypeNOName" name="" placeholder="" type="text" class="form-control required" />
                <input id="FContainerTypeNO"  name="" type="hidden" class="form-control required" />
            </div>
        </li>
        <li class="form_item form_item_2">
            <label>备注说明</label>
            <div class="input_c input_c_2">
                <input id="FDescription" name="" placeholder="" type="text" class="form-control required" />
            </div>
        </li>
    </ul>
    <div class="tool_c">
        <div class="input_c btn-group  input-width-185">
            <label>容器编号</label>
            <input id="FContainerNO1" style="width: 140px;" class="form-control" type="text" />
        </div>
        <div class="btn-group">
            <a id="btn_search1" class="btn btn-primary center-block"><span class="glyphicon glyphicon-search"></span>&nbsp查询</a>
        </div>
    </div>
    <div class="grid_list_1_c">
        <table id="gridList1"></table>
        <div id="gridPager1"></div>
    </div>
</div>

